import {StackScreenProps} from '@react-navigation/stack';
import * as React from 'react';
import {StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {AuthContext} from "../../App";
import AsyncStorage from "@react-native-community/async-storage";

export default function LoginScreen({}: StackScreenProps<any, 'Login'>) {

  const {examineToken} = React.useContext(AuthContext);
  return (
    <View style={styles.container}>
      <TouchableOpacity onPress={() => {
        AsyncStorage.setItem('userToken','123').finally(()=>examineToken());
      }} style={styles.link}>
        <Text style={styles.linkText}>登陆</Text>
      </TouchableOpacity>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    padding: 20,
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold',
  },
  link: {
    marginTop: 15,
    paddingVertical: 15,
  },
  linkText: {
    fontSize: 14,
    color: '#2e78b7',
  },
});
